//
//  CNKITabViewController.m
//  CNKICommunity
//
//  Created by wei on 17/1/23.
//  Copyright © 2017年 CNKI. All rights reserved.
//

#import "CNKITabViewController.h"
#import "CNKINavViewController.h"
#import "HomeViewController.h"
#import "ActivityViewController.h"
#import "MessageViewController.h"
#import "IndividualViewController.h"
#import "CNTabbar.h"

@interface CNKITabViewController ()

@end

@implementation CNKITabViewController

+(void)initialize
{
   //设置tabbarge点击效果
    NSMutableDictionary *NormalStateDic = [NSMutableDictionary dictionary];
    NormalStateDic[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    NormalStateDic[NSForegroundColorAttributeName] = [UIColor grayColor];
    
    NSMutableDictionary *SelectStateDic = [NSMutableDictionary dictionary];
    SelectStateDic[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    SelectStateDic[NSForegroundColorAttributeName] = [UIColor darkGrayColor];
    
    UITabBarItem *item = [UITabBarItem appearance];
    [item setTitleTextAttributes:NormalStateDic forState:UIControlStateNormal];
    [item setTitleTextAttributes:SelectStateDic forState:UIControlStateSelected];
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self SetChildViewController:[[HomeViewController alloc] init] Title:@"首页" Image:[UIImage imageNamed:@"tabBar_essence_icon"] SelectImage:[UIImage imageNamed:@"tabBar_essence_click_icon"]];
    [self SetChildViewController:[[ActivityViewController alloc] init] Title:@"活动" Image:[UIImage imageNamed:@"tabBar_friendTrends_icon"] SelectImage:[UIImage imageNamed:@"tabBar_friendTrends_click_icon"]];
    [self SetChildViewController:[[MessageViewController alloc] init] Title:@"消息" Image:[UIImage imageNamed:@"tabBar_new_icon"] SelectImage:[UIImage imageNamed:@"tabBar_new_click_icon"]];
    [self SetChildViewController:[[IndividualViewController alloc] init] Title:@"我" Image:[UIImage imageNamed:@"tabBar_me_icon"] SelectImage:[UIImage imageNamed:@"tabBar_me_click_icon"]];
    
    //自定义tabbar
    [self setValue:[[CNTabbar alloc]init] forKey:@"tabBar"];
}

-(void)SetChildViewController:(UIViewController *)childController Title:(NSString *)title Image:(UIImage*)image SelectImage:(UIImage*)selectImage
{
    childController.navigationItem.title = title;
    childController.tabBarItem.title = title;
    childController.tabBarItem.image = image;
    childController.tabBarItem.selectedImage = selectImage;
    
    //包装Nav
    CNKINavViewController *nav = [[CNKINavViewController alloc]initWithRootViewController:childController];
    
    [self addChildViewController:nav];
    NSLog(@"数目%ld",(unsigned long)self.viewControllers.count);
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
    
}



@end
